﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.TaskControlBack"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:ViewModel="clr-namespace:ScrumTable.UI.ViewModel;assembly=ScrumTable.UI.ViewModel"
    xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:CustomControl="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl" Opacity="0.95" Height="300"  Background="#FFEFEFEF" MaxWidth="1024" Width="800" 
    x:Name="ControlRoot"> 
    <UserControls:ScrumUserControl.Resources>
        <Converter:ConverterNotBool x:Key="NotBool"/>
        <Converter:ConverterBoolVisibility x:Key="IsVisible"/>
        <Converter:CalcConverter x:Key="Calc" CalcType="Multi" ValueRight="3.2"/>
    </UserControls:ScrumUserControl.Resources>

    <UserControls:ScrumUserControl.IsEnabled>
        <Binding Path="IsDisposed" Converter="{StaticResource NotBool}"/>
    </UserControls:ScrumUserControl.IsEnabled>
    
    <Grid >
        <Grid.Resources>
            <Converter:ConverterNotBoolVisibility x:Key="ConverterNotBoolVisibility"/>
            <Converter:ConverterBoolVisibility x:Key="ConverterBoolVisibility"/>
            <Converter:ConverterNullableDouble x:Key="NullableDouble" />
        </Grid.Resources>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="Auto" Name="AttributRow"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="400"/>
            <ColumnDefinition MinWidth="{Binding ElementName=ControlRoot, Path=ConfigManager.Config.ControlSize.X}" MaxWidth="{Binding ElementName=ControlRoot, Path=ConfigManager.Config.ControlSize.X, Converter={StaticResource Calc}}" />
        </Grid.ColumnDefinitions>
        
        <Label FontSize="12" Grid.Row="0" HorizontalAlignment="Left"  VerticalAlignment="Center">
            <Label.Content>
                <Localization:Translate Uid="Task_Title" Default="[Title]" />
            </Label.Content>
        </Label>

        <CustomControl:ValidateTextBox Margin="70,5,5,5" Text="{Binding Path=Name}" x:Name="Title" ValidateRegex=".+"/>
        <UserControl Grid.Row="1" VerticalAlignment="Top" Name="PropertyPart"/>
        
        <UserControl Name="MemoPart" Grid.Row="2" FontSize="12" Margin="3,0,3,0" />

        <Grid  Grid.Row="0" Grid.Column="1" Grid.RowSpan="6" Margin="3,3,3,1">
            <Grid.Resources>
                <Converter:CalcConverter CalcType="Add" ValueRight="50" x:Key="AddMargin"/>
                <Converter:CalcConverter CalcType="Add" ValueRight="10" x:Key="AddMargin10"/>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="15"/>
                <RowDefinition Height="0.7*"/>
                <RowDefinition Height="18"/>
                <RowDefinition Height="{Binding ElementName=ControlRoot, Path=ConfigManager.Config.ControlSize.Y, Converter={StaticResource AddMargin10}}"/>
            </Grid.RowDefinitions>


            <UserControls:SurfaceDragDropListBox MinWidth="{Binding ElementName=ControlRoot, Path=ConfigManager.Config.ControlSize.X, Converter={StaticResource AddMargin}}"
                x:Name="AttachmentList"
                MultipleColumnsRows="True"
                BorderThickness="1,0,1,1"
                Opacity="0.75"            
                AllowDrop="False"                  
                ItemsSource="{Binding Path=AttachmentsAsViewModel}"
                ItemsAreStatic="True"
                Orientation="Vertical"            
                DragOnMove="False"            
                Grid.Row="1">
                <UserControls:SurfaceDragDropListBox.ItemTemplate>
                    <DataTemplate>
                        <UserControls:AttachmentControl ChangeDefaultWidth="0.5" ChangeDefaultHeight="0.5"/>
                    </DataTemplate>
                </UserControls:SurfaceDragDropListBox.ItemTemplate>
            </UserControls:SurfaceDragDropListBox>
            <UserControls:AddButton ButtonType="Attachment" Click="OnAddAttachmentClick" FontWeight="Bold" FontSize="20" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Right" VerticalAlignment="Top" Width="32" Height="32" Grid.Row="1"></UserControls:AddButton>

            <Border Grid.Row="3" BorderBrush="{Binding ElementName=AttachmentList, Path=BorderBrush}" BorderThickness="1,0,1,1"  Padding="3">
                <UserControls:UserStoryControl x:Name="ParentUserStory"  ChangeToStretch="True" DataContext="{Binding Path=ParentAsStoryViewModel}" Margin="0"/>
            </Border>

            <Border CornerRadius="2,2,0,0" BorderBrush="{Binding ElementName=AttachmentList, Path=BorderBrush}" BorderThickness="1,1,1,0" Background="{StaticResource ListBoxBackground}">
                <Label Opacity="0.75" Content="{Localization:Translate Default=[Attachment], Uid=General_Attachment}" Margin="0" Padding="0" Grid.Column="1"  HorizontalContentAlignment="Center" VerticalAlignment="Top" />
            </Border>
            <Border CornerRadius="2,2,0,0" Grid.Row="2" BorderBrush="{Binding ElementName=AttachmentList, Path=BorderBrush}" BorderThickness="1,1,1,0" Margin="0,3,0,0" Background="{StaticResource ListBoxBackground}">
                <Label Opacity="0.75" Content="{Localization:Translate Default=[Parent], Uid=General_Parent}"  Padding="0"   Grid.Column="1"  HorizontalContentAlignment="Center" VerticalAlignment="Top" />
            </Border>

        
        </Grid>

        <Border Margin="20,0,20,0" Background="LightGray" Opacity="0.8" Grid.ColumnSpan="10" Grid.RowSpan="10" BorderBrush="Black" BorderThickness="0.5" CornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center"  Visibility="{Binding IsDisposed, Converter={StaticResource IsVisible}}">
            <TextBlock Margin="5" FontStyle="Italic" FontSize="30" Text="{Localization:Translate Uid=Global_Element_Moved, Default=[Element was moved on the server]}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Border>        
    </Grid> 
</UserControls:ScrumUserControl>
